<?php
define('IN_QY',true);
session_start();
require("include/common.inc.php");
require_once('config.php');
require_once('qq.php');
include_once( 'wbconfig.php' );
include_once( 'saetv2.ex.class.php' );
$o = new SaeTOAuthV2( WB_AKEY , WB_SKEY );
$code_url = $o->getAuthorizeURL( WB_CALLBACK_URL );
if($qq_t!=''){
    $qq=new qqPHP($qq_k, $qq_s, $qq_t);
    $qq_oid=$qq->get_openid();
    $openid=$qq_oid['openid']; //获取登录用户open id
    //获取登录用户信息
    $result=$qq->get_user_info($openid);
//	 echo "<script type='text/javascript'>alert('使用QQ快捷登录成功');location.href='qqwelcome.php';</script>";
//    exit;
}else{
    //生成登录链接
    $qq=new qqPHP($qq_k, $qq_s);
    $login_url=$qq->login_url($callback_url, $scope);
}
if($_GET['act']=='login'){
    $sql = "select * from tbl_user where userid ='".$_POST['userid']."' AND userpwd ='".$_POST['userpwd']."'";
    $query = mysql_query($sql);
    $row = mysql_fetch_array($query);
    if($row){
        setcookie("username",$row['userid'],time()+(3600*8*1*1),"/");
        setcookie("userid",$row['id'],time()+(3600*8*1*1),"/");
        setcookie("shuyu",$row['shuyu'],time()+(3600*8*1*1),"/");
        setcookie("addmima",strtotime($row['change_pwd_time']),time()+(3600*8*1*1),"/");
//	
        if($_COOKIE['popped']){
            echo "<script type='text/javascript'>location.href='".$_COOKIE['popped']."';</script>";
        }else {
            echo "<script type='text/javascript'>location.href='mlogin.php';</script>";
        }
    } else{
        echo "<script type='text/javascript'>alert('用户名或密码不正确');location.href='mlogin.php';</script>";
        exit;
    }
}

if($_COOKIE['userid']){
    echo "<script type='text/javascript'>location.href='main.php';</script>";
    exit;
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>验证码登录-众晒网</title>
    <link rel="stylesheet" href="/ui/login/css/base.css" />
    <script src="/wap/dl/lib/jquery-2.1.4.js"></script>
    <style>
        ::-webkit-input-placeholder {
            /* WebKit browsers */
            color: #CCCCCC!important;
        }

        :-moz-placeholder {
            /* Mozilla Firefox 4 to 18 */
            color: #CCCCCC!important;
        }

        ::-moz-placeholder {
            /* Mozilla Firefox 19+ */
            color: #CCCCCC!important;
        }

        :-ms-input-placeholder {
            /* Internet Explorer 10+ */
            color: #CCCCCC!important;
        }

        #geetest_holder geetest_wind geetest_radar_click_hide{
            width:  261px;
        }
        #embed-captcha {
            width:  261px;
            margin: 7px auto;
        }
        .show {
            display: block;
        }
        .hide {
            display: none;
        }
        .t {
            margin-left:13px;
            text-decoration:none;
        }
        .nav {
            margin-top: 16%;
            height: auto;
            overflow: hidden;
            padding-bottom: 2rem;
        }
        .nav ul {
            height: auto;
            overflow: hidden;
            clear: both;
        }
        .nav ul li {
            width: 15%;
            float: left;
            margin-left: 13%;
            font-size: 1.2rem;
            text-align: center;
            margin-top: 2rem;
            line-height: 1.5rem;
        }
        .nav ul li img {
            width: 100%;
            -webkit-animation-delay: 1.5s;
            -webkit-animation-duration: 2s;
        }
        #notice {
            color: red;
        }

        a{
            text-decoration:none;
            color:#FE984C;


        }


    </style>
</head>
<body>
<div class="bg_bank">
    <a class="re_bank" href="javascirpt:;" onclick="javascript:history.back(-1);"></a>
    <div class="re_min_infor">

        <div class="bg_color">

            <div class="re_min">

                <input class="input01" name="userid" id="userid" type="text" placeholder="请输入手机号" />

            </div>
            <div class="re_min">

                <input class="input01" name="code" id="code" type="password" placeholder="输入验证码" />
                <input  type="button" class="reto_code" id="send_code"   value="获取验证码" name="phone" onclick="showtime(60)"/>

            </div>

        </div>

        <div class="re_regist" style="margin-top:-23px;">
            <button class="btn_regist" id="btn" onclick="btn()" >登录</button>
        </div>

        <div class="re_regist" style="margin-top:11px;">
            <button onclick="window.location.href='yzmlogin.php'" class="btn_regist" type="button" style="background-color: #cccccc;border: 1px solid #cccccc;">账号登录</button>
        </div>

        <div class="re_regist02">
            <!------------
                <a class="t" id="dl"  style="text-decoration:none;color: #fe984c;">注册</a>
            ------------------------>
            <a class="t" href="mmregister.php"  style="text-decoration:none;color: #fe984c;">注册</a>

            <a class="t" href="javascript:void(0)" onclick="_MEIQIA('showPanel')" style="text-decoration:none;color: #fe984c;" >客服</a>

            <a class="t" href="xiugaimima.php"  style="text-decoration:none;color: #fe984c;">忘记密码</a>
        </div>
        <div class="nav">
            <ul>
                <li>
                    <a href="<?=$login_url?>">
                        <p><img src="/ui/login/img/icon_QQ登录@3x.png" class="animated bounceIn"></p>
                    </a>
                </li>
                <li>
                    <?php

                    // 是否微信中打开
                    function is_weixin() {
                        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
                            return true;
                        } return false;
                    }
                    $is_weixin = (is_weixin() == true) ? "1" : "2";
                    ?>
                    <?php
                    if($is_weixin==1){
                        ?>
                        <a href="wxlogin.php">
                            <p><img src="/ui/login/img/微信登录@3x.png" class="animated rotateIn"></p>
                        </a>
                    <?php } ?>
                    <?php
                    if($is_weixin==2){
                        ?>
                        <a href="javascirpt:;" onclick="alert('请在微信APP中打开!');">
                            <p><img src="/ui/login/img/微信登录@3x.png" class="animated rotateIn"></p>
                        </a>
                    <?php } ?>
                </li>
                <li>
                    <a href="<?=$code_url?>">
                        <p><img src="/ui/login/img/微博登录@3x.png" class="animated rotateIn"></p>
                    </a>
                </li>
            </ul>
        </div>

    </div>
</div>
<script type="text/javascript" src="/ui/layer/mobile/layer.js"></script>
<!-- 这是美洽的嵌入代码 -->
<script type='text/javascript'>
    (function(m, ei, q, i, a, j, s) {
        m[i] = m[i] || function() {
            (m[i].a = m[i].a || []).push(arguments)
        };
        j = ei.createElement(q),
            s = ei.getElementsByTagName(q)[0];
        j.async = true;
        j.charset = 'UTF-8';
        j.src = 'https://static.meiqia.com/dist/meiqia.js?_=t';
        s.parentNode.insertBefore(j, s);
    })(window, document, 'script', '_MEIQIA');
    _MEIQIA('entId', '65407');

    // 在这里开启无按钮模式（常规情况下，需要紧跟在美洽嵌入代码之后）
    _MEIQIA('withoutBtn');
</script>
<script type='text/javascript'>
    // 当你使用了「手动初始化」时，就可以在自己的逻辑中选择合适的时机调用 withoutBtn
    // 只要是在美洽初始化之前，就可以被正确执行
    _MEIQIA('withoutBtn');
    _MEIQIA('init');
</script>

<!-- 这是美洽的嵌入代码 -->
<!-- 这是美洽的嵌入代码 -->
<script>

    function showtime(){
		
		var flag = 1;  
var i = 55;  
function countDown() {  

 var div = document.getElementById("send_code");
    i = i - 1;  
	 div.style.setProperty('background-color','#cccccc');	
	$("#send_code").attr("disabled","disabled");
    $("#send_code").val(i+"秒后重新发送");  
	
    if (i == 0) {  
	 div.style.setProperty('background-color','#fe984c');
	 
	$("#send_code").removeAttr("disabled");;
        $("#send_code").val("重新发送");  
        flag = 1;  
        i = 55;  
        return;  
    }  
    setTimeout('countDown()',1000);  
} 

        var phone=document.getElementById("userid").value;

        if(phone==""){
            layer.open({
                content: '请输入手机号'
                ,skin: 'msg'
                ,time: 2
            });
            return false;

        }
        $.ajax({
            url: './sms_send.php',
            type: 'POST',
            dataType: 'json',
            data: {phone: phone},
        })
            .done(function(respon) {
                if (respon.error==1) {
                    layer.open({
                        content: '验证码发送成功'
                        ,skin: 'msg'
                        ,time: 2
                    });
					countDown();

                }else{

                    layer.open({
                        content: '发送失败'
                        ,skin: 'msg'
                        ,time: 2
                    });



                }
            })

    }

</script>
<script>

    function btn(){
        var dlphone=document.getElementById("userid").value;
        var dlcode=document.getElementById("code").value;
        if(dlphone==""){
            layer.open({
                content: '请输入手机号'
                ,skin: 'msg'
                ,time: 2
            });
            return false;

        }
        if(dlcode==""){
            layer.open({
                content: '请输入验证码'
                ,skin: 'msg'
                ,time: 2
            });
            return false;

        }

        $.ajax({
            url: './yzmloginapi.php',
            type: 'POST',
            dataType: 'json',
            data: {
                dlphone: dlphone,
                dlcode: dlcode

            },
        })
            .done(function(respon) {
                if (respon.error==0) {
                    layer.open({
                        content: '登录成功'
                        ,skin: 'msg'
                        ,time: 2
                    });

                    if(respon.popped==1){
                        setTimeout(function(){

                            window.location.href="index.php";

                        },1900);

                    }else{
                        setTimeout(function(){

                            window.location.href=respon.popped;

                        },1900);



                    }


                }

                if (respon.error==1) {
                    layer.open({
                        content: '验证码不正确'
                        ,skin: 'msg'
                        ,time: 2
                    });
                    return false;
                }

                if (respon.error==2) {
                    layer.open({
                        content: '手机号未注册'
                        ,skin: 'msg'
                        ,time: 2
                    });
                    return false;
                }


            })
    }

</script>



</body>
</html>